package com.xian.ucenter.utils;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xian.ucenter.commons.Result;
import com.xian.ucenter.entities.Post;
import org.springframework.stereotype.Component;

@Component
public class PageUtil<T> {
    public Result pageList(Integer current, Integer count, ServiceImpl service, Wrapper<T> wrapper) {
        Page<T> page = new Page<>(current,count);
        service.page(page,wrapper);
        return Result.ok().data("total",page.getTotal()).data("pages",page.getPages()).data("current",page.getCurrent()).data("list",page.getRecords());
    }
}
